package com.ygqh.baby.model;

import java.util.Map;

import org.apache.commons.lang.StringUtils;

import com.alibaba.fastjson.JSON;
import com.ygqh.baby.po.ScheduleJob;

/**
 * 
 * @Description: 计划任务信息
 */

public class SchJob extends ScheduleJob {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public static final String STATUS_RUNNING = "1";
	public static final String STATUS_NOT_RUNNING = "0";
	public static final String CONCURRENT_IS = "1";// 任务是否有状态
	public static final String CONCURRENT_NOT = "0";

	private Map<String, Object> dataMap;

	public SchJob() {
		super();
	}

	public SchJob(Map<String, Object> dataMap) {
		super();
		this.dataMap = dataMap;
	}

	public SchJob(String jobName, String jobGroup, String jobType, Integer jobTimes, String cron, String description, String springId, String methodName,
			Map<String, Object> dataMap) {
		super(jobGroup, jobName, STATUS_RUNNING, jobType, jobTimes, cron, description, CONCURRENT_NOT, null, springId, methodName,
				dataMap == null ? null : JSON.toJSONString(dataMap));

		this.dataMap = dataMap;
	}

	@SuppressWarnings("unchecked")
	public Map<String, Object> getDataMap() {
		if (dataMap != null) {

			return dataMap;
		}
		if (StringUtils.isNotBlank(super.getData())) {
			return JSON.parseObject(super.getData(), Map.class);
		}
		return null;
	}

	public void setDataMap(Map<String, Object> dataMap) {
		this.dataMap = dataMap;
	}

}